<include file="public@header" />
<style type="text/css">
    #changes {
        width:90%; position:absolute;
        top:35px; list-style:none;
        background:#FFF; border:1px solid #dde6e9;
        display:none; padding:3px;z-index: 1;
        overflow-x: auto;
        height: 200px;
    }
    .on_changes{}
    .on_changes li{margin:0px;padding:6px;font-size: 14px;text-align: left;}
    .on_changes li.active{ background:#CEE7FF;}
</style>
<script type="text/javascript" src="__STATIC__/js/gaopaiyi/gpy.js?v={:time()}"></script>
</head>
<body onload="onLoad(1)">
<div class="wrap  ">
    <div class="container" style="padding: 0px 150px">
        <div class="row">
            <div class="col-md-12  ">
                <h1 class="text-center" style="padding: 100px 0">客户登录售后</h1>
                    <form  class="form-horizontal js-ajax-form" method="post" action="{:url('login')}" >
                        <fieldset>
                            <div class="form-group" style="text-align: center"  >
                                <label class="col-sm-4 control-label" style="width: 26%;"><span class="form-required">* </span>客户身份证号码：</label>
                                <div class="col-sm-4">
                                    <input type="text" class="form-control"style="width: 100%;" name="buyer_cart" id="buyer_cart" placeholder="请输入客户身份证号码">
                                    <div id="changes">
                                        <ul class="on_changes"></ul>
                                    </div>
                                </div>
                                <div class="col-md-4" style="width: 22%">
                                    <a   class="btn btn-info" id="singleReadIDCard" value="" >读取身份证</a>
                                    <a   class="btn btn-primary" id="searchware"   >搜索</a>
                                </div>
                            </div>
                        </fieldset>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript" src="__STATIC__/js/admin.js?v={:time()}"></script>
<script type="text/javascript">
    document.onkeydown = function(event) {
        var target, code, tag;
        if (!event) {
            event = window.event; //针对ie浏览器
            target = event.srcElement;
            code = event.keyCode;
            if (code == 13) {
                tag = target.tagName;
                if (tag == "TEXTAREA") { return true; }
                else { return false; }
            }
        }
        else {
            target = event.target; //针对遵循w3c标准的浏览器，如Firefox
            code = event.keyCode;
            if (code == 13) {
                tag = target.tagName;
                if (tag == "INPUT") { return false; }
                else { return true; }
            }
        }
    };
    $('#singleReadIDCard').click(function () {
        console.log(123)
        ReadIDCard(0,function (json) {
            $('#buyer_cart').val(json.empIndentity);
        })
    })
    $("#searchware").click(function(){
        // 控制下拉框显示
        var display =$('.on_changes');
        if(display.is(':hidden')){
            //如果node是隐藏的则显示node元素，否则隐藏
            //$("#changes").show();
        }else{
            $("#changes").hide();
        }
        $.ajax({
            url:"{:url('login')}",
            type:'GET',
            data:"ajax=1&buyer_cart="+ $("#buyer_cart").val(),
            success:function(dataObj){
                $(".on_changes").html('')
                if (dataObj.data.length>0){
                    $("#changes").show();
                    $.each(dataObj.data,function(idx,item){
                        var tlt='',color='';
                        if(item.tomb_typei==1){ 
                            if (item.deposit_state==1){
                                tlt = '<label>（寄出）</label>';
                            }
                            var li = "<li class='choose' data-item='"+JSON.stringify(item)+"'  onmouseover='this.style.backgroundColor=\"#ffff66\";'onmouseout='this.style.backgroundColor=\"#fff\";'>"+
                                item.buyer_name+"【墓位编号："+item.tomb_num+"】位置："+
                                item.tomb_region+item.tomb_address+item.tomb_bit_number+
                                "</li>";
                        }else {
                            if (item.status==3){
                                tlt = '（退款）';
                            }else if (item.move_status==0) {
                                tlt = '（已迁出）'
                            }
                        }
                        var li = "<li class='choose' data-item='"+JSON.stringify(item)+"'  onmouseover='this.style.backgroundColor=\"#ffff66\";'onmouseout='this.style.backgroundColor=\"#fff\";'>"+
                            tlt+ item.buyer_name+"【墓位编号："+item.tomb_num+"】位置："+
                            item.tomb_region+item.tomb_address+item.tomb_bit_number+
                            "</li>";
                          $(".on_changes").append(li);
                    });
                }else {
                    layer.msg('信息错误'); 
                    $("#changes").hide();
                }
            }
        });
    });
    $('ul').bind('click','.choose',function (e) {
        var json  =eval('(' +  e.target.dataset.item + ')');
        $.post("{:url('login')}",{id:json.id,tomb_id:json.tomb_id,tomb_type:json.tomb_type}, function(result){
            window.location.href = "{:url('shouindex')}";
        }, 'json');
    })

    </script>
</body>
</html>